package com.bingxue.edu.teacher.controller;

import com.bingxue.edu.framework.common.model.Response;
import com.bingxue.edu.management.auth.EmployeeAuthUtil;
import com.bingxue.edu.teacher.model.query.BaseTeacherQuery;
import com.bingxue.edu.teacher.model.resp.LessonEvaluationDetailResp;
import com.bingxue.edu.teacher.model.resp.LessonEvaluationResp;
import com.bingxue.edu.teacher.service.ParentEvaluationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 教师端小程序家长评价模块
 * @author zq
 * @since 2024/10/13
 */
@Tag(name = "教师端小程序-家长评价")
@RestController
@RequestMapping("/t/parentEvaluation")
@RequiredArgsConstructor
public class TeacherClassEvaluationController {

    private final ParentEvaluationService parentEvaluationService;

    @Operation(summary = "教师端小程序家长评价-查询教师所有的课次数据-教师id")
    @GetMapping("/get")
    public Response<List<LessonEvaluationResp>> getTeacherLessonInfos() {
        BaseTeacherQuery query = new BaseTeacherQuery();
        String currentUserId = EmployeeAuthUtil.getCurrentUserId();
        if (EmployeeAuthUtil.isAssistTeacher()) {
            query.setAssistTeacherId(currentUserId);
        } else {
            query.setLeadTeacherId(currentUserId);
        }
        return Response.success(parentEvaluationService.getLessonEvaluation(query));
    }

    @Operation(summary = "教师端小程序家长评价-查询评价详情数据-课次id")
    @GetMapping("/detail/{id}")
    public Response<List<LessonEvaluationDetailResp>> getLessonEvaluationDetail(@PathVariable String id) {
        return Response.success(parentEvaluationService.getLessonEvaluationDetail(id));
    }
}
